package tech.runchen.gz5055.oms.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import tech.runchen.gz5055.oms.common.utils.MapUtils;
import tech.runchen.gz5055.oms.modules.system.entity.OrderDetailEntity;
import tech.runchen.gz5055.oms.modules.system.entity.ReturnOrderDetailEntity;
import tech.runchen.gz5055.oms.modules.system.mapper.ReturnOrderDetailMapper;
import tech.runchen.gz5055.oms.modules.system.service.IReturnOrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 退货单明细表 服务实现类
 * </p>
 *
 * @author zzj
 * @since 2023-12-20
 */
@Service
public class ReturnOrderDetailServiceImpl extends ServiceImpl<ReturnOrderDetailMapper, ReturnOrderDetailEntity> implements IReturnOrderDetailService {

    @Override
    public void saveReturnOrderDetailBatch(Long returnOrderId, List<ReturnOrderDetailEntity> returnOrderDetailList) {
        if (returnOrderDetailList == null || returnOrderDetailList.size() == 0) {
            return;
        }
        for (ReturnOrderDetailEntity returnOrderDetail : returnOrderDetailList) {
            returnOrderDetail.setReturnOrderId(returnOrderId);
            this.save(returnOrderDetail);
        }
    }

    @Override
    public List<ReturnOrderDetailEntity> queryReturnOrderDetailList(Long returnOrderId) {
        return this.list(new QueryWrapper<ReturnOrderDetailEntity>().eq("return_order_id", returnOrderId));
    }

    @Override
    public void deleteByReturnOrderIdBatch(Long returnOrderId) {
        this.removeByMap(new MapUtils().put("return_order_id", returnOrderId));
    }
}
